package cs340.stormtroopers.junitTests.phase4BlackBox;

import java.util.HashSet;
import java.util.Random;

import cs340.stormtroopers.hypeerweb.Node;
import junit.framework.TestCase;

public class BradBlackBox extends TestCase
{
	public void testEquivalencePartitioning()
	{
		Node n = new Node(7);
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());
		
		for(int i = 0; i<13; i++)
			n.addNeighbor(new Node(i));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 5);
		
		n = new Node(7);
		for(int i = 0; i<7; i++)
			n.addNeighbor(new Node(i));
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());
		
		n = new Node(7);
		for(int i = 8; i<13; i++)
			n.addNeighbor(new Node(i));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 5);
		
		n = new Node(7);
		for(int i = 7; i<13; i++)
			n.addNeighbor(new Node(i));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 5);
		
		Random r = new Random();
		n = new Node(10);
		HashSet<Integer> added = new HashSet<Integer>();
		for(int i = 0; i <= 10; i++){
			int c = r.nextInt(20);
			if(c>10)
				added.add(c);
			n.addNeighbor(new Node(c));
		}
		assertTrue(n.getNeighborsBiggerThanMe().size() == added.size());
	}

	public void testExternalBoundaryAnalysis()
	{
		Node n = new Node(4);
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());

		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());

		n = new Node(4);
		n.addNeighbor(new Node(4));
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());

		n = new Node(4);
		n.addNeighbor(new Node(5));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 1);

		n = new Node(4);
		n.addNeighbor(new Node(4));
		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());

		n = new Node(4);
		n.addNeighbor(new Node(5));
		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 1);

		n = new Node(4);
		n.addNeighbor(new Node(4));
		n.addNeighbor(new Node(5));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 1);

		n = new Node(4);
		n.addNeighbor(new Node(4));
		n.addNeighbor(new Node(5));
		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 1);

		n = new Node(3);
		n.addNeighbor(new Node(6));
		n.addNeighbor(new Node(5));
		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 2);

		n = new Node(4);
		n.addNeighbor(new Node(4));
		n.addNeighbor(new Node(5));
		n.addNeighbor(new Node(6));
		assertTrue(n.getNeighborsBiggerThanMe().size() == 2);

		n = new Node(4);
		n.addNeighbor(new Node(4));
		n.addNeighbor(new Node(1));
		n.addNeighbor(new Node(0));
		assertTrue(n.getNeighborsBiggerThanMe().isEmpty());
	}
}
